package com.cloudy.s3.request;


import com.cloudy.exception.S3AccessException;
import com.cloudy.impl.S3ObjectAsString;
import com.cloudy.s3.response.CreateBucketConfiguration;
import com.cloudy.s3.response.LocationConstraint;

import static com.cloudy.utility.CloudyUtility.*;

public class CreateBucket extends S3RequestWithNoResponse{

	
	public CreateBucket(String bucketName) {
		super(bucketName, "PUT");
	}
	public CreateBucket(String bucketName, LocationConstraint location) throws S3AccessException {
		this(bucketName);
		CreateBucketConfiguration configuration = new CreateBucketConfiguration();
		configuration.setLocationConstraint(location);
//		super.body = configuration;
		S3ObjectAsString obj = new S3ObjectAsString();
		String xml = marshalTheObject(configuration);
		obj.setContent(xml);
		obj.setContentType("");
		obj.setContentLength(xml.length());
		super.setS3Object(obj);
	}
}
